function loginFormCtrl($scope, $http, $state) {
    // $scope.teacher = [];

    $scope.user = null;

    $scope.login = function () {
    	console.log("start loging");
    	console.log("user.accountName"+ $scope.user.accountName);

        $http({

            url: '/userLogin/login',
            method: 'POST',
            data: $scope.user

        }).success(function (response) {

            console.log("response: " + response);

           // var message = response["message"]

            //var content = response["content"]
            var message = response.resultMessage;

            if (message == "success") {

               // localStorage.setItem("token", "Bearer " + content)
               // console.log("whole token： " + localStorage.getItem("token"))
                console.log("scope.user: "+$scope.user.accountName);
                $state.go('userCenter',{accountName : $scope.user.accountName,password: $scope.user.password});
            }

        }).error(function (response) {
            alert('error')
        })


    };

    $scope.reset = function(){
    	$scope.user = angular.copy($scope.user);
    };

    $scope.gotoRegister = function () {
        $state.go('register');
    };

    $scope.register = function () {
        console.log("registerUser.accountName: "+$scope.registerUser.accountName);
        $http({
            url: '/userLogin/register',
            method: 'POST',
            data: $scope.registerUser

        }).success(function (response) {

            console.log("response: " + response);

            // var message = response["message"]

            //var content = response["content"]
            var message = response.resultMessage;

            if (message == "success") {

                // localStorage.setItem("token", "Bearer " + content)
                // console.log("whole token： " + localStorage.getItem("token"))
                console.log("scope.user: "+$scope.registerUser.accountName);
                $state.go('login');
            }

        }).error(function (response) {
            alert('error')
        })


    };

    $scope.returnToLogin = function () {
        $state.go('login');
    }



}

function RegisterCtrl($scope, $http) {
    // $scope.wrong = false;
    $scope.teacher = null;

    $scope.register = function () {

        $http({

            url: '/userLogin/register',
            method: 'post',
            params: $scope.user
        }).success(function (response) {

            if (response['code'] == 200) {

                $state.go('login');
            } else {

                alert(response['content']);

            }
        })
    }
}

